{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}

{% set modalSize = 'large' %}

{% block title %}{{'添加'|trans}}{% if setting('default.user_name') %}{{ setting('default.user_name')|default('学员'|trans) }}{% else %}{{'学员'|trans}}{% endif %}{% endblock %}
{% block body %}

<form id="student-create-form" class="form-horizontal" method="post" action="{{ path('course_manage_student_create', {id:course.id}) }}">
  {% if course.status == 'published' %}
  	<div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="student-nickname">{% if setting('default.user_name') %}{{ setting('default.user_name')|default('学员'|trans) }}{% else %}{{'学员'|trans}}{% endif %}</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="student-nickname" name="queryfield" class="form-control"
        data-url="{{ path('course_manage_student_check',{id:course.id})}}" placeholder='{{'邮箱/手机/用户名'|trans}}' >
      	<div class="help-block">{{'只能添加系统中已注册的用户'|trans}}</div>
    	</div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="buy-price">{{'购买价格'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <div class="input-group">
          <input type="text" id="buy-price" name="price" value="{{ course.price }}" class="form-control">
          <div class="input-group-addon">{{'元'|trans}}</div>
        </div>
        <div class="help-block">{{'本课程的价格为'|trans}}{{course.price}}{{'元'|trans}}</div>
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="student-remark">{{'备注'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="student-remark" name="remark" class="form-control">
        <div class="help-block">{{'选填'|trans}}</div>
      </div>
    </div>
  {% else %}
    <div class="empty">{{dict_text('courseStatus', course.status)}}{{'课程不能添加'|trans}}{% if setting('default.user_name') %}{{ setting('default.user_name')|default('学员'|trans) }}{% else %}{{'学员'|trans}}{% endif %}，{{'请课程发布后再添加。'|trans}}</div>
  {% endif %}

  <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">

</form>

{% endblock %}

{% block footer %}
  {% if course.status == 'published' %}
    <button id="student-create-form-submit" type="submit" class="btn btn-primary pull-right" data-toggle="form-submit" data-target="#student-create-form" data-submiting-text="{{'正在保存'|trans}}..." data-user="{{ default.user_name|default('学员'|trans) }}">{{'保存'|trans}}</button>
  {% endif %}
  <button type="button" class="btn btn-link pull-right" data-dismiss="modal">{{'取消'|trans}}</button>
  <script>app.load('course-manage/student-create')</script>
{% endblock %}
